﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Scheduler.Business_Logic_Layer
{
    /**Class: Employee
     * @author Sara Tuohy
     * @version 1.0
     * Course : ITEC 4860 Spring, 2012
     * Written: March, 2012
     * Class to make employee attributes easily accessible
     * 04062012 implement IComparable and add ToString() method sft
     */
    class Employee : IComparable
    {
        /**
         * Employee Name                */ 
        public string Name  { get; set; }
        /**
        * Employee Phone               */
        public string Phone { get; set; }
        /**
        * Employee Email               */
        public string Email { get; set; }
        /**
        * Employee Employee ID         */
        public string EmpID { get; set; }
        /**
         * used for IComparable        */ 
        protected string m_value;

        /**Method: Employee
         * Constructor
         * @param string empName Employee name
         * @param string empPhone Employee phone
         * @param string empEmail Employee email
         * @param string empID Employee ID
         */
        public Employee(string empName, string empPhone, string empEmail, string empID)
        {
            Name  = empName;
            Phone = empPhone;
            Email = empEmail;
            EmpID = empID;
            //ToString() method includes ID which must be unique; to deal with duplicate names ...
            m_value = this.ToString();
        }

        /**Method: CompareTo
         * Required by the IComparable interface
         * Purpose: allow array of Employee to sort
         * @param object obj object to compare to
         * @return int string comparison value 
         */ 
        public int CompareTo(object obj)
        {
            if (obj is Employee)
            {
                Employee tempEmp = (Employee)obj;
                return m_value.CompareTo(tempEmp.m_value);
            }
            throw new ArgumentException("object is not an Employee");
        }

        /**Method: Value
         * Getter and Setter for the value used to compare
         */ 
       public string Value
       {
           get {
               return m_value;
           }
           set {
               m_value = value;
           }
       }

        /**Method: ToString
         * Override the object ToString method
         * Purpose: provide a meaningful employee representation
         * If needed, a ToStringLong can be added to include additional information (phone, email, etc.)
         * @return string of concatenated name and ID
         */
       public override string ToString()
        {
            string nameAndId = this.Name.Trim() +"  (" + this.EmpID.Trim() + ")";
            return nameAndId;
        }
    }
}
